<template>
	<view class="backgd1">
		<view class="container">
			<view class="top-menu0">
				<view @click="getHelpList" class="">
					求救
				</view>
				<view @click="getGoodsList" class="">
					救援
				</view>
				<view @click="getVolunteersList" class="">
					志愿者
				</view>
				<view class="">
					首页
				</view>
			</view>
			<view class="top-menu1">
				位置
				<!-- <select>
					<option v-for="(item,index) in cityList">{{item.name}}</option>
				</select>
				<select>
					<option>金水</option>
				</select> -->

			</view>
			<view class="top-menu2">
				<text style="margin: auto;">需要:</text>
				<textarea class="input1" type="text" v-model='inputContent' />
				<view @click="serchFor" class="search-btn btn-currency">
					搜索
				</view>
			</view>
			<view class="info-menu">
				<view class="icon-add btn-currency" @click="getHelp()">

					发布求救信息

				</view>
				<view class="icon-add btn-currency" @click="getGoods()">

					发布物资信息

				</view>
				<view class="icon-add my-info btn-currency" @click="myInfo">
					我的
				</view>
			</view>
			<!-- 求救信息列表 -->
			<view class="info-lists" v-for="(item,index) in dataInfo" :key="index">
				<view class="right-title">
					{{item.rescueType == 1? '求救信息':'物资信息'}}
				</view>
				<view class="info-list">
					<!-- <view class="">人数：</view> -->
					<!-- <view class="">{{item.trappedPersons}}</view> -->
				</view>
				<view class="info-list">
					<view class="gray-item">位&nbsp;&nbsp;&nbsp;&nbsp;置：</view>
					<view class="">{{item.address}}</view>
				</view>
				<view class="info-list">
					<view class="gray-item">电&nbsp;&nbsp;&nbsp;&nbsp;话：</view>
					<view class="">{{item.mobilePhone}}</view>
				</view>
				<view class="info-list">
					<view class="gray-item">固&nbsp;&nbsp;&nbsp;&nbsp;话：</view>
					<view class="">{{item.tel}}</view>
				</view>
				<view class="info-list">
					<view class="gray-item">联系人：</view>
					<view class="">{{item.contactsPerson}}</view>
				</view>
				<view class="info-list">
					<view class="gray-item">描&nbsp;&nbsp;&nbsp;&nbsp;述：</view>
					<rich-text :nodes="item.material"></rich-text>
				</view>
				<view class="info-list-btn">
					<view @click="sendNews" class="btn-currency">最新情况反馈</view>
					<view class="btn-currency">复制转发</view>
				</view>
				<view class="user-info">
					<view class="user-head">
						<image :src="headImgUrl" mode=""></image>

					</view>
					<view class="user-name">
						{{nickName}}
					</view>
					<view class="">
						发布时间：{{item.createTime}}
					</view>
				</view>
			</view>

			<!-- 物资信息列表 -->
			<!-- <view class="info-lists">
				<view class="right-title">
					提供物资
				</view>
				<view class="info-list">
					<view class="">物资名称：</view>
					<view class="">双人皮划艇</view>
				</view>
				<view class="info-list">
					<view class="">数量：</view>
					<view class="">20</view>
					<view class="">单位：</view>
					<view class="">艘</view>
				</view>
				<view class="info-list">
					<view class="">物资名称：</view>
					<view class="">救生衣</view>
				</view>
				<view class="info-list">
					<view class="">数量：</view>
					<view class="">20</view>
					<view class="">单位：</view>
					<view class="">件</view>
				</view>
				<view class="info-list">
					<view class="">电话：</view>
					<view class="bold-text">12345678910</view>
				</view>
		
				<view class="info-list">
					<view class="">联系人：</view>
					<view class="bold-text">郭靖</view>
				</view>
				<view class="info-list-btn">
					<view class="">最新情况反馈</view>
					<view class="">复制转发</view>
				</view>
				<view class="user-info">
					<view class="user-head">
		
					</view>
					<view class="user-name">
						微信昵称
					</view>
					<view class="">
						发布时间：2021/7/23
					</view>
					
				</view>
				<view class="jishuzhichi">
						技术支持：13781981469王丹
				</view>
			</view>
			</view>
			</view> -->
		</view>
		
	</view>

</template>

<script>
	import location from './location.js'
	var jweixin = require('jweixin-module');
	var _this;
	export default {
		data() {
			return {

				// baseUrl:"http://192.168.3.30:8085/jeecg-boot/",
				baseUrl: "http://weixiaokong.91xiaokong.com/jeecg-boot/",
				cityList: [],
				inputContent: '',
				dataInfo: [],
				openId: "ogiDYs4eDr9DA2pofZeYsFQygtt4",
				nickName: "Hank%3F",
				headImgUrl: 'https%3A%2F%2Fthirdwx.qlogo.cn%2Fmmopen%2Fvi_32%2FDYAIOgq83eppjoSew4ibQEbRGM2sYZiap6Hk8GR3YX6wEJsbMgyySeRLiaIzFLDrKkqCwHOF5leB061JA7cnu1XMg%2F132',
				selectedValue: [],
				fileUrl: '',

			}

		},
		onLoad(options) {
			console.log(options);
			// console.log(location[0].children);
			// this.getUserInfo();
			this.cityList = location[0].children
			_this = this;
			uni.request({
				url: this.baseUrl + 'rescue/hnjzRescueInformation/list', //仅为示例，并非真实接口地址。
				data: {
					address: '河南'
				},
				success: (res) => {
					_this.dataInfo = res.data.result.records

				},
				fail(err) {
					console.log(err);
				}
			});
			this.getAccess();
		},
		methods: {
			// 授权接口
			// getUserInfo() {
			// 	uni.request({
			// 		url:this.baseUrl+'wx/mp/wxLoginShare'
			// 	})

			// },
			// getUserInfo() {
			// 	window.location.href = this.baseUrl + "wx/mp/wxLoginShare"

			// },

			// 获取签名
			getAccess() {
				let that = this;
				// alert(location.href.split('#')[0]);

				var jiekouUrl = window.location.href;

				uni.request({
					// url:'http://chewei.mynatapp.cc/jeecg-boot/wx/user/getWXToken',					
					url: that.baseUrl + 'wx/user/getWXToken',
					data: {
						// shareUrl: 'http://chewei.mynatapp.cc/#/?noticeId=1406788377667973121&phone=18203895809'
						// 	shareUrl: 'http://article.weixiaokong.com/#/?openid=ogiDYs7VebisnjEjBfpOFkSPI8_c&nickname=Slyer&noticeId=1406788377667973121&phone=18203895809'
						// },
						shareUrl: jiekouUrl,
					},
					success(res) {
						that.nonceStr = res.data.nonceStr;
						that.signature = res.data.signature;
						that.timestamp = res.data.timestamp;
						that.shareUrl = res.data.url;

						jweixin.config({
							debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
							appId: 'wx778f313eff0f980b', // 必填，公众号的唯一标识
							timestamp: that.timestamp, // 必填，生成签名的时间戳
							nonceStr: that.nonceStr, // 必填，生成签名的随机串
							signature: that.signature, // 必填，签名
							jsApiList: ['updateAppMessageShareData',
								'updateTimelineShareData',
								'onMenuShareAppMessage',
								'onMenuShareTimeline'
							] // 必填，需要使用的JS接口列表
						});
						jweixin.ready(function() {

							_this.fileUrl =
								"https://cdn.91xiaokong.com/chewei/files/20210725/720_default_1627194500734.jpg";

							_this.fileUrl =
								"https://static.jeecg.com/temp/%E5%9B%BD%E7%82%AC%E8%BD%AF%E4%BB%B6logo_1606575029126.png";

							_this.fileUrl =
								"https://static.jeecg.com/temp/%E5%9B%BD%E7%82%AC%E8%BD%AF%E4%BB%B6logo_1606575029126.png";

							var shareData = {
								title: '应急救援信息', // 分享标题
								desc: '在这一场抗洪抢险灾后重建中，希望所有参与志愿者放下自我，放平心态，多些包容和理解。各区域工作组组长和特别工作组长务必听从指挥，完成下达任务！', // 分享描述
								link: jiekouUrl, // 分享链接 
								imgUrl: _this.fileUrl,
								// 'https://shengrun.91xiaokong.com/chewei/files/20210628/static.jisutui_1624862899900.jisutui.jpg',
								// imgUrl: "https://shengrun.91xiaokong.com/chewei/" + that
								// .sharePicUrl, // 分享图标
								type: '', // 分享类型,music、video或link，不填默认为link
								dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
								success: function() {
									// alert("分享微信好友成功！");
									that.getShare();
								},
								cancel: function() {
									// alert('分享微信好友失败');
								}
							};

							jweixin.updateAppMessageShareData(shareData);
							jweixin.updateTimelineShareData(shareData);


						});
					}
				})
				// config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。

				// uni.request({
				// 	url: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx778f313eff0f980b&secret=910415b15c96d7268cc1ee899f5fc8cd',
				// 	success(res) {
				// 	}
				// })
				// window.location.href = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx778f313eff0f980b&secret=910415b15c96d7268cc1ee899f5fc8cd',

			},
			// 查询求救信息列表
			// getHelpList(){
			// },
			serchFor() {
				console.log(_this.inputContent);
				uni.request({
					url: this.baseUrl + 'rescue/hnjzRescueInformation/list', //仅为示例，并非真实接口地址。
					data: {
						material: _this.inputContent
					},
					success: (res) => {
						_this.dataInfo = res.data.result.records

					},
					fail(err) {
						console.log(err);
					}
				});
			},
			
			getGoods() {
				uni.navigateTo({
					url: '../help_reg/help_reg?openId=' + this.openId,
				})
			},
			myInfo() {
				console.log('123');
				uni.navigateTo({
					url: '../my_info/my_info?openId=' + this.openId,
				})
			},
			sendNews() {
				uni.navigateTo({
					url: '../new_info/new_info'
				})
			},
			handleChange(selectedValue, clickItem) {
				console.log('handleChange', selectedValue, clickItem)
				this.selectedValue = selectedValue
			}
		}
	}
</script>

<style scoped>
	.backgd1 {
		padding-bottom: 140rpx;
	}

	.container {
		/* 
		background-image: url(../../static/help/backg1.png);
		width: 100%;
		height: 100%; */
		margin-left: 15rpx;
		font-size: 30rpx;
	}

	.top-menu0 {
		display: flex;
		margin-left: 30rpx;
		margin-right: 45rpx;
		height: 80rpx;
		line-height: 80rpx;
		justify-content: space-around;
		border-top: 1rpx #ccc solid;
	}

	.add-icon {
		font-size: 100rpx;
		/* margin-bottom: 200rpx; */
	}

	.top-menu1 {
		display: flex;
		margin-left: 30rpx;
		margin-right: 45rpx;
		border-top: solid 1rpx #ccc;
		height: 50rpx;
		padding-top: 20rpx;
	}

	.top-menu1 select {
		margin-left: 20rpx;
	}

	.top-menu2 {
		display: flex;
		height: 130rpx;
		margin-left: 30rpx;
		margin-right: 45rpx;
		margin-top: 20rpx;
		border-bottom: solid 1rpx #ccc;
		/* background-color: #bfa; */
	}

	.top-menu2 .input1 {
		width: 60%;
		height: 100rpx;
		margin-left: 20rpx;
		border: 1rpx #000 solid;
		margin-top: 0rpx;
		border-radius: 40rpx;
		margin: auto;
	}

	.search-btn {
		width: 100rpx;
		height: 40rpx;
		margin-top: 40rpx;
		margin-left: 50rpx;
		border: 1rpx #000 solid;
		border-radius: 30rpx;
		font-size: 30rpx;
		padding: 10rpx;
		text-align: center;
		margin: auto;
	}

	.icon-add {
		border: 1rpx #000 solid;
		border-radius: 30rpx;
		padding:10rpx 20rpx;
	}

	.info-menu {
		/* width: 100%; */
		height: 100rpx;
		/* background-color: #baf; */
		margin: 0 45rpx 0 30rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
		/* border-bottom: #ccc solid 1rpx; */
	}

	/* 信息列表 */
	.right-title {
		position: absolute;
		right: 0;
		top: 0;
		font-size: 40rpx;
		color: #ccc;
	}

	.info-lists {
		position: relative;
		height: 640rpx;
		border: 1rpx #706d6c;
		margin-right: 45rpx;
		margin-left: 30rpx;
		overflow: scroll;
		box-shadow: 0px 0px 30px 0px rgba(0, 0, 0, 0.1);
		padding: 40rpx 10rpx;
	}

	.info-lists>view {
		margin-top: 10rpx;

	}


	.info-list,
	.info-list-btn {
		display: flex;
		/* margin-top: 10rpx; */
	}

	.info-list view {
		/* margin-left: 30rpx; */
		/* overflow: scroll; */
	}

	.info-list rich-text {
		/* margin-right: 20rpx; */
		/* width: 30rpx; */
		margin-left: 20rpx;
	}


	.bold-text {
		font-size: 40rpx;
		font-weight: bold;
	}

	.info-list-btn {
		justify-content: flex-end;
	}

	.info-list-btn>view {
		/* border: 1rpx #000 solid; */
		margin-right: 20rpx;
		border-radius: 30rpx;
		padding: 10rpx;
	}

	.user-info {
		display: flex;
		justify-content: flex-end;
	}

	.user-info view {
		margin-right: 20rpx;
		margin-top: 20rpx;
		font-size: 28rpx;
	}

	.user-head,
	.user-head image {
		width: 40rpx;
		height: 40rpx;
		/* background-color: #baf; */
		border-radius: 20rpx;
	}

	.jishuzhichi {
		display: flex;
		justify-content: flex-end;
		color: #ccc;
		font-size: 20rpx;
	}

	.scrool {
		height: 160rpx;
		overflow-y: scroll;
	}

	.btn-currency{
		background-color: #b30002;
		color: #FFFFFF;
		border: none;
	}
	.gray-item{
		/* width: 120rpx; */
		color: #aaaaaa;
		/* text-align: center; */
	}
</style>
